﻿/*
Flash Name: 好乐买首页 JS切换图
Description: 首页js轮播（业务QQ940009267）
*/
document.write('<div id="flash_cycle_image"></div>');
$importjs = (function()
{
    var uid = 0;
    var curr = 0;
    var remove = function(id)
    {
        var head = document.getElementsByTagName('head')[0];
        head.removeChild( document.getElementById('jsInclude_'+id) );
    };

    return function(file,callback)
    {
        var callback;
        var id = ++uid;
        var head = document.getElementsByTagName('head')[0];
        var js = document.createElement('script');
        js.setAttribute('type','text/javascript');
        js.setAttribute('src',file);
        js.setAttribute('id','jsInclude_'+id);
        if( document.all )
        {
            js.onreadystatechange = function()
            {
                if(/(complete|loaded)/.test(this.readyState))
                {
                    try
                    {
                        callback(id);remove(id);
                    }
                    catch(e)
                    {
                        setTimeout(function(){remove(id);include_js(file,callback)},2000);
                    }
                }
            };
        }
        else
        {
            js.onload = function(){callback(id); remove(id); };
        }
        head.appendChild(js);
        return uid;
    };
}
)();
function LoadCSS(url){
	var s = document.createElement("LINK");
	s.rel = "stylesheet";
	s.type = "text/css";
	s.href = url;
	document.getElementsByTagName("HEAD")[0].appendChild(s);
}

function show_flash()
{
var mylnk=links.split("|");
var mytxt=texts.split("|");
var mypic=pics.split("|");
var s1="",s2="",s3="";
cpn=mylnk.length;
for(i=0;i<mylnk.length;i++)
{
	s1+='<li id="Myop'+i+'" ></li>';
	s2+='<li  id="Myjs'+i+'" onmouseover="Myjsch(\'Myjs'+i+'\',\''+mypic[i]+'\')" onmouseout="Myjscl(\'Myjs'+i+'\')"  ref="'+mypic[i]+'"><a href="'+unescape(mylnk[i])+'">'+mytxt[i]+'</a></li>';
	}
    document.getElementById('flash_cycle_image').innerHTML = '<div class="i_topcenter">'+"\n"+'<div class="slides" >'+"\n"+'<img id="slide-pic" src="'+mypic[0]+'"/>'+"\n"+'<ul class="slide-li" id="op">'+"\n"+s1+"\n"+'</ul><ul class="slide-li"  id="slide-txt">'+"\n"+s2+'</ul>'+"\n"+'</div>'+"\n"+'  </div>';
	
	
document.getElementById("Myjs0").style.background="#2c6abd";
if(document.all)document.getElementById("slide-pic").filters[0].enabled=false;
ss="";
timen=2000;
cp=0;
obj=document.getElementById("slide-pic");
cpn=document.getElementById("slide-txt").getElementsByTagName("li").length;
ss= window.setInterval(function() { 
		
			 if(cp<cpn-1){cp++;	 } else{ cp=0	 }
			 if(document.all){
				obj.filters.blendtrans.Apply();
				obj.filters[0].enabled=false;
				obj.filters.blendtrans.Play();
				}
				obj1=
				obj.src=document.getElementById("Myjs"+cp).getAttribute("ref");
				for(j=0;j<cpn;j++){
				if(j==cp){
					obj1=document.getElementById("Myjs"+j).style.background="#2c6abd";
					}
				else
				{	document.getElementById("Myjs"+j).style.background="";
				}
				}
				
				
	  },timen);





//mystart();	
	}
	
	
	
	
LoadCSS("data/flashdata/Myjs/mycss.css");
$importjs('data/flashdata/Myjs/data.js', show_flash);

function Myjsch(sid,ref)
{       window.clearInterval(ss);
	        if(document.all){
            obj.filters.blendtrans.Apply();
			obj.filters[0].enabled=false;
			obj.filters.blendtrans.Play();
				}
			obj.src=ref;
			
	for(i=0;i<cpn;i++)
	{
		if("Myjs"+i==sid)
		{	document.getElementById("Myjs"+i).style.background="#2c6abd";}
		else
		{
			document.getElementById("Myjs"+i).style.background="";
			}
		}
	
	}

function Myjscl(sid)
{
cp=sid.substring(4);
ss= window.setInterval(function() { 
		
			 if(cp<cpn-1){cp++;	 } else{ cp=0	 }
			 if(document.all){
				obj.filters.blendtrans.Apply();
				obj.filters[0].enabled=false;
				obj.filters.blendtrans.Play();
				}
				obj1=
				obj.src=document.getElementById("Myjs"+cp).getAttribute("ref");
				for(j=0;j<cpn;j++){
				if(j==cp){
					obj1=document.getElementById("Myjs"+j).style.background="#2c6abd";
					}
				else
				{	document.getElementById("Myjs"+j).style.background="";
				}
				}
				
				
	  },timen);


}